<template>
  <div class="app-container">
    <div style="margin-top: 20px">
    <!--搜索-->
    <el-form :inline="true" :model="listQuery" size="mini" label-width="130px">

      <el-form-item label="订单号：">
        <el-input v-model="listQuery.orderSn"></el-input>
      </el-form-item>
      <el-form-item label="采购单号：">
        <el-input v-model="listQuery.purchaseOrderSn"></el-input>
      </el-form-item>
      <el-form-item label="牌号：">
        <el-select v-model="listQuery.sapGoodsId" filterable placeholder="请选择" clearable>
          <el-option
            v-for="item in goodsList"
            :key="item.kingId"
            :label="item.goodsSn"
            :value="item.kingId">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          @click="handleSearchList()"
          type="primary">
          查询
        </el-button>
      </el-form-item>
    </el-form>
  </div>
    <div class="table-container">
      <el-table
        v-loading="listLoading"
        :data="tableData"
        border
        row-key="ownershipId"
        border
        default-expand-all
        :tree-props="{children: 'sonList', hasChildren: 'hasChildren'}"
        style="width: 100%;">
          <el-table-column
            prop="chargeUser"
            align="center"
            label="货权人">
          </el-table-column>
          <el-table-column
            align="center"
            prop="goodsSn"
            label="牌号">
          </el-table-column>
          <el-table-column
            align="center"
            prop="goodsNum"
            label="数量">
          </el-table-column>
          <el-table-column
            align="center"
            prop="goodsPrice"
            label="价格">
          </el-table-column>
          <el-table-column
            align="center"
            prop="chargeTime"
            label="转移时间">
          </el-table-column>


      </el-table>
    </div>
    <div class="pagination-container">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        layout="total, sizes,prev, pager, next,jumper"
        :current-page.sync="listQuery.pageNum"
        :page-size="listQuery.pageSize"
        :page-sizes="[10,15,20]"
        :total="count">
      </el-pagination>
    </div>
  </div>
</template>
<script>
import {orderGoodsList} from '@/api/partner'
import {ownershipMoveReport} from '@/api/order'
import { mapGetters } from 'vuex'
import store from '@/store'
const defaultListQuery={
  "sapGoodsId" : '', //商品ID
  "purchaseOrderSn" : "", //采购单号
  "orderSn" : "", //订单号
  "pageNum" : 1,
  "pageSize" : 10


};
export default {
  name: "index",
  data(){
    return {
      listQuery: JSON.parse(JSON.stringify(defaultListQuery)),
      tableData: [],
      count: 0,
      listLoading: false,
      roles:store.getters.roles ? store.getters.roles : [],
      goodsList:[]
    }
  },
  components: {

  },
  computed: {
    ...mapGetters([
      'name',
      'mobile',
      'userId'
    ]),


  },
  created() {
    this.getList()
    orderGoodsList().then((res)=>{
      this.goodsList = res.list
    })
  },
  filters: {


  },
  methods: {


    /**
     * 切换选择状态
     */
    handleSelect(key, keyPath){
      this.listQuery = JSON.parse(JSON.stringify(defaultListQuery))
      this.listQuery.tab = key;
      this.handleSearchList();
    },
    handleSizeChange(val){
      this.listQuery.pageNum = 1;
      this.listQuery.pageSize = val;
      this.getList();
    },
    handleCurrentChange(val){
      this.listQuery.pageNum = val;
      this.getList();
    },

    handleSearchList(){
      this.listQuery.pageNum = 1;
      this.getList();
      this.getSum()
    },

    //获取列表
    getList() {
      this.listLoading = true;
      ownershipMoveReport(this.listQuery).then(response => {
        this.tableData = response.list;
        this.count = response.count;
        this.listLoading = false;
      }).catch(()=>{
        this.listLoading = false;
      });
    },




  },
}
</script>


